module.exports = function ($scope, $modalInstance, $resource, toaster,bean) {

  $scope.bean = bean;
  $scope.sendlist = [
    {'id': '1', 'name': '一级分销商', 'value': true},
    {'id': '2', 'name': '二级分销商', 'value': true},
    {'id': '3', 'name': '三级分销商', 'value': true}
  ]

  $scope.ok = function(){
    var aa = [];
    $scope.sendlist.forEach(element => {
      if(element.value){
        aa.push(element.id);
      }
    });
    var para = {
      'product_code': bean.product_code,
      'level': aa.toString()
    }
    if(para.level == '1,2,3'){
      delete para.level
    }
    $resource('/api/ac/mc/merchantNoticeService/createProductUpNotice', {}, {}).save(para, function (res) {
      if(res.errcode === 0){
        toaster.success({title: '', body: '推送消息成功'});
      }else{
        toaster.error({title: '', body: '推送消息成功失败'});
      }
    });
  }

  $scope.cancel = function(){
    $modalInstance.close();
  }

};